package com.hyacinth.core.sysmgr.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

import com.hyacinth.common.framework.ServiceSupport;
import com.hyacinth.core.sysmgr.domain.SysMenu;
import com.hyacinth.core.sysmgr.service.IMenuService;

@Component("menuService")
public class MenuService extends ServiceSupport<SysMenu> implements IMenuService {

	@Override
	public List<SysMenu> all() {
		return super.all();
	}
	
	private List<SysMenu> treeFormat(List<SysMenu> menus, Long id) {
		List<SysMenu> tmp = new ArrayList<SysMenu>();
		for(SysMenu m : menus) {
			if(m.getPid() == id) {
				m.setChildren(treeFormat(menus, m.getId()));
				tmp.add(m);
			}
		}
		return tmp;
	}
	
}
